#include "finddialog.h"
#include "ui_finddialog.h"
#include <QDebug>
#include <QMessageBox>

findDialog::findDialog(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::findDialog)
{
    ui->setupUi(this);
    setWindowTitle("查找");
    setWindowFlags(Qt::WindowCloseButtonHint|Qt::Drawer);
    connect(ui->findLineEdit,SIGNAL(textChanged(QString)),this,SLOT(slotContentChanged()));
    connect(ui->findBtn,SIGNAL(clicked(bool)),this,SLOT(slotFindDialog()));
}

findDialog::~findDialog()
{
    delete ui;
}
void findDialog::slotFindDialog()
{
    if(ui->findLineEdit->text().isEmpty()){
        return;
    }
    QString strContent = ui->findLineEdit->text();
    if(ui->downBtn->isChecked()){
        if(ui->ignoCK->isChecked()){
            emit signalfind(strContent,true,true);
        }else{
            emit signalfind(strContent,false,true);
        }
    }
    if(ui->uoBtn->isChecked()){
        if(ui->ignoCK->isChecked()){
            emit signalfind(strContent,true,false);
        }else{
            emit signalfind(strContent,false,false);
        }
    }
}

void findDialog::slotContentChanged()
{
    if(ui->findLineEdit->text().trimmed().isEmpty()){
        ui->findBtn->setDisabled(true);
    }
    else{
        ui->findBtn->setDisabled(false);
    }
}



void findDialog::on_cancelBtn_clicked()
{
    this->close();
}
